package com.example.demo.control;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2017-6-9.
 */
@RestController
@RequestMapping
public class RmFileControl {

    Logger logger = LoggerFactory.getLogger(RmFileControl.class);


    @RequestMapping("/rm/file")
    public String index(String file, HttpServletRequest request) {
        logger.info("rm file");
        if (LoginUtil.valid(request)) return "no login , 刷新后再试";
        try {
            String jenname = SessionUtil.jenkinsname(request);
            com.example.demo.others.jenkins.Jenkins.run(jenname, file );
//            Files.delete(Paths.get(AutoPushUtil.base_source_dir + file));
        } catch (Exception e) {
            logger.info("err{}", e);
            return "err" + e.getMessage();
        }
        return "success";
    }

}
